<template>
  <ContentWrap>
    <el-descriptions :column="1" border>
      <el-descriptions-item label="用户ID">
        {{ detailData.userId }}
      </el-descriptions-item>
      <el-descriptions-item label="流程编号">
        {{ detailData.processInstanceId }}
      </el-descriptions-item>
      <el-descriptions-item label="申报类型">
        <dict-tag :type="DICT_TYPE.CX_FORM_TYPE" :value="detailData.type" />
      </el-descriptions-item>
      <el-descriptions-item label="开始时间">
        {{ formatDate(detailData.startTime, 'YYYY-MM-DD HH:mm:ss') }}
      </el-descriptions-item>
      <el-descriptions-item label="结束时间">
        {{ formatDate(detailData.endTime, 'YYYY-MM-DD HH:mm:ss') }}
      </el-descriptions-item>
      <el-descriptions-item label="机构名字">
        {{ detailData.agencyName }}
      </el-descriptions-item>
    </el-descriptions>
  </ContentWrap>
</template>
<script lang="ts" setup>
import { DICT_TYPE } from '@/utils/dict'
import { formatDate } from '@/utils/formatTime'
import { propTypes } from '@/utils/propTypes'
import { DeclarationInfoApi } from '@/api/bpm/declarationinfo'

defineOptions({ name: 'BpmDeclarationInfoDetail' })

const { query } = useRoute()

const props = defineProps({
  id: propTypes.number.def(undefined)
})
const detailLoading = ref(false)
const detailData = ref<any>({})
const queryId = query.id as unknown as number

const getInfo = async () => {
  detailLoading.value = true
  try {
    detailData.value = await DeclarationInfoApi.getDeclarationInfo(props.id || queryId)
  } finally {
    detailLoading.value = false
  }
}
defineExpose({ open: getInfo })

onMounted(() => {
  getInfo()
})
</script>
